from sqlalchemy import Column, Integer, String, DateTime
from sqlalchemy.sql import func

from app.config import Base

class Airport(Base):
    __tablename__ = "airports"

    id = Column(Integer, primary_key=True, index=True)
    name = Column(String(100), nullable=False)
    code = Column(String(10), unique=True, index=True, nullable=False)
    city = Column(String(50), nullable=False)
    country = Column(String(50), nullable=False)
    created_at = Column(DateTime(timezone=True), server_default=func.now())
    updated_at = Column(DateTime(timezone=True), onupdate=func.now())

    def __repr__(self):
        return f"<Airport {self.code}>"
